<template>
  <div>
    <Row>
      <i-col span="24">
        <Card>
          <Button class="opt-btn" @click="confirmSelection" type="primary">确认选择</Button>
          <Button class="opt-btn" @click="showSearchModal" type="primary">高级搜索</Button>
          <Tooltip class="opt-btn" content="刷新" placement="right">
            <Button icon="md-refresh" type="success" shape="circle" @click="searchTable(false, false)"></Button>
          </Tooltip>
                    <Tooltip class="opt-btn" content="重置搜索" placement="right">
                        <Button icon="md-repeat" type="success" shape="circle" @click="researchTable"></Button>
                    </Tooltip>
          <GoodsAttributeTableSingle
            ref="table"
            v-on:searchTable="searchTable"
            v-on:showDetailModal="showDetailModal"
          />
        </Card>
      </i-col>
    </Row>
    <GoodsAttributeSearchModal ref="searchModal" v-on:searchTable="searchTable" />
    <GoodsAttributeDetailModal ref="detailModal" />
  </div>
</template>

<script>
import * as utils from '@/api/utils-v2'
import GoodsAttributeTableSingle from './GoodsAttributeTableSingle.vue'
import GoodsAttributeSearchModal from './GoodsAttributeSearchModal.vue'
import GoodsAttributeDetailModal from './GoodsAttributeDetailModal.vue'
export default {
  name: 'GoodsAttributeMainMultiple',
  components: {
    GoodsAttributeTableSingle,
    GoodsAttributeSearchModal,
    GoodsAttributeDetailModal
  },
  data() {
    return {
      selectedData: [],
      selectedDataIdProp: '',
      extraData: {}
    }
  },
  computed: {},
  mounted() {},
  methods: {
    searchTable(reset, clearOldData) {
      utils.search(this, reset, clearOldData)
    },
    researchTable() {
      this.$refs.searchModal.resetForm()
      setTimeout(() => {
          utils.search(this, true)
      }, 10);
    },
    showDetailModal(row) {
      let detailModal = this.$refs.detailModal
      detailModal.modal.detail = true
      detailModal.form = row
	  detailModal.getDictItemsDisplayValue()
    },
    showSearchModal() {
      let searchModal = this.$refs.searchModal
      searchModal.modal.search = true
    },
    confirmSelection() {
      // 确认选择的逻辑
      const row = this.$refs.table.table.currentRow
      if (!row.id) {
        this.$Message.error('请选择一行数据')
        return
      }
      this.$emit('confirmChoice', row)
    }
  }
}
</script>

<style>
</style>
